#pragma once

#include "Common.h"
//#include "ObjectPool.hpp"

class ThreadCache
{
	using Self = ThreadCache;

public:

	ThreadCache() = default;
	~ThreadCache();

	ThreadCache(const Self&) = delete;
	ThreadCache(Self&&) = delete;

	Self& operator=(const Self&) = delete;
	Self& operator=(Self&&) = delete;

	void* allocate(size_t);

	void deallocate(void*, size_t);

	void* fetchFromCentralCache(size_t, size_t);

	void listTooLong(FreeList&, size_t, size_t);

private:

	FreeList _freeLists[RIGHT_NFREELIST];
};

//static ObjectPool<ThreadCache> ThreadPool;
//static thread_local std::unique_ptr<ThreadCache, ThreadPool.Delete> pTLSThreadCache = nullptr;
static thread_local std::unique_ptr<ThreadCache> pTLSThreadCache = nullptr;
//static _declspec(thread) ThreadCache* pTLSThreadCache = nullptr;

